<template>
  <div>
    <el-form
      ref="typeForm"
      :model="form"
      label-width="50px"
    >
      <el-row>
        <el-col :md="7" :lg="7">
          <el-form-item label="名称:">
            <el-input
              v-model="form.name"
              size="medium"
              placeholder="请输入名称"
            />
          </el-form-item>
        </el-col>
        <el-col :md="7" :lg="7">
          <el-form-item label="类型:">
            <el-select v-model="form.type" placeholder="请选择" clearable>
              <el-option
                label="车辆品牌"
                value="0"
              />
              <el-option
                label="车辆类型"
                value="1"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :md="10" :lg="10" style="text-align: right">
          <el-form-item>
            <el-button
              type="primary"
              size="medium"
              @click="onSubmit('typeForm')"
            >
              搜索
            </el-button>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>

<script>
export default {
  name: 'TypeForm',
  data() {
    return {
      form: {
        name: '',
        type: ''
      }
    }
  },
  methods: {
    onSubmit(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.$emit('on-success-valid', {
            name: this.form.name,
            type: this.form.type
          })
        } else {
          return false
        }
      })
    }
  }
}
</script>
<style scoped>
  .el-input{
    width: 180px;
  }
</style>
